<template>
  <el-card class="mt-10">
    <template #header>
      <div class="category-rank__header">
        <span>分类销售排行</span>

        <el-radio-group v-model="selectedValue" size="small">
          <!-- label：选中的value值 -->
          <el-radio-button label="category">品类</el-radio-button>
          <el-radio-button label="goods">商品</el-radio-button>
        </el-radio-group>
      </div>
    </template>

    <PieChart
      :data="selectedValue === 'category' ? category : goods"
      :title="selectedValue === 'category' ? '品类分布' : '商品分布'"
    />
  </el-card>
</template>

<script lang="ts">
export default {
  name: "CategoryRank",
};
</script>

<script lang="ts" setup>
import { ref } from "vue";
import PieChart from "./PieChart.vue";

defineProps<{
  category: any;
  goods: any;
}>();

const selectedValue = ref("category");
</script>

<style scoped>
.mt-10 {
  margin-top: 10px;
}

.category-rank__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
